package com.automation.ljf.converter;

import com.automation.ljf.util.CommonUtil;
import com.automation.ljf.domain.dataobject.CaseReportDO;
import com.automation.ljf.domain.po.CaseReportPO;
import com.automation.ljf.domain.vo.CaseReportVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * CaseReport实体转换器
 *
 * @author lijiefeng
 * @since 2021/8/30
 */
@Component
public class CaseReportConvert {

    public CaseReportPO caseReportDOToPO(CaseReportDO caseReportDO, String reportId){
        if (caseReportDO == null){
            return null;
        }
        CaseReportPO caseReportPO = new CaseReportPO();
        caseReportPO.setId(CommonUtil.generateOID())
                .setCaseId(caseReportDO.getCaseId())
                .setReportId(reportId)
                .setCaseName(caseReportDO.getCaseName())
                .setCaseUrl(caseReportDO.getCaseUrl())
                .setCaseDetail(caseReportDO.getCaseDetail())
                .setAdmUserId(caseReportDO.getAdmUserId())
                .setCaseResult(caseReportDO.getCaseResult())
                .setCreateTime(new Date())
                .setUpdateTime(new Date());
        return caseReportPO;
    }

    public CaseReportDO caseReportPOToDO(CaseReportPO caseReportPO){
        if (caseReportPO == null){
            return null;
        }
        CaseReportDO caseReportDO = new CaseReportDO();
        BeanUtils.copyProperties(caseReportPO, caseReportDO);
        return caseReportDO;
    }

    public CaseReportVO caseReportDOToVO(CaseReportDO caseReportDO){
        if (caseReportDO == null){
            return null;
        }
        CaseReportVO caseReportVO = new CaseReportVO();
        BeanUtils.copyProperties(caseReportDO, caseReportVO);
        return caseReportVO;
    }


}
